package com.tzl.design_pattern.delegate_pattern;

import java.util.HashMap;
import java.util.Map;

/**
 * 经理类:负责分发任务给员工
 *
 * @author Zhilei Tang
 * @date Created in 2020/11/14 17:59
 */
public class Manager implements IEmployee {

  protected final Map<String, IEmployee> workTarget = new HashMap<>();

  public Manager() {
    workTarget.put("部署项目", new Employee_A());
    workTarget.put("修复bug", new Employee_B());
  }

  @Override
  public void work(String taskCommand) {
    IEmployee employee = workTarget.get(taskCommand);
    if (employee == null) {
      System.out.println("没有可以执行任务的员工");
      return;
    }
    employee.work(taskCommand);
  }
}
